package com.example.demo.service;

import com.example.demo.entity.Classes;
import com.example.demo.entity.Subscribe;
import com.example.demo.mapper.ClassesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassesService {
    @Autowired
    private ClassesMapper classesMapper;

    private int save(Classes classes) { return classesMapper.insert(classes);}

    //查询预约实验室现有容量
    public int existCount(String name){
        return classesMapper.existCount(name);
    }

    //查询预约实验室编号
    public int labId(int labType, int lab){
        String temp = "" + lab;
        return classesMapper.labId(labType,temp);
    }

    //修改预约实验室的容量
    public void editCount(String type,int count,int id){
        if(type.equals("个人预约")){
            classesMapper.editCount(count-1, id);
        }else{
            classesMapper.editCount(0, id);
        }
    }

    //分页查询数据
    public List<Classes> selectPage(Integer pageNum, Integer pageSize){
        return classesMapper.selectPage(pageNum,pageSize);
    }
    //查询不同类型的所有数据
    public List<Classes> labTypeSelect(Integer labType){
        return classesMapper.labTypeSelect(labType);
    }
    //查询不同类型的所有数据,分页显示
    public List<Classes> labTypeSelectPage(Integer labType,Integer pageNum,Integer pageSize){
        return classesMapper.labTypeSelectPage(labType,pageNum,pageSize);
    }

    //根据id获取实验室详情
    public Classes getDetail(Integer id){
        return classesMapper.getDetail(id);
    }
}